// pages/merchant/order/order.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        touxiang: '',
        text: '',
        time: '',
        shouyi: '',
        zhuangtai: '',
        yizhifu: [],
        daizhifu: [],
        active: 0
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        that.setData({
            fsid: options.fsid,
            touxiang: wx.getStorageSync('userInfo'),
        })
        wx.showLoading({
            title: '加载中',
        })
        this.getlist()
    },
    change1() {
        this.setData({
            active: 0
        })
    },
    change2() {
        this.setData({
            active: 1
        })
    },
    getlist() {
        var that = this;
        //获取佣金明细
        wx.request({
            // url: con.index_getread,
            url: 'https://www.brvpmusic.com/certification/selectFranchiseOrder/list',
            method: 'GET',
            data: {
                'fsid': that.data.fsid,
            },
            header: {
                'Content-Type': 'application/json'
            },
            success: function(res) {
                wx.hideLoading()
                console.log(res.data);
                console.log('经销商订单返回成功');
                var yizhifu = []
                var daizhifu = []
                res.data.body.forEach(element => {
                    if (element.oOrderstatus === 0) {
                        daizhifu.push(element)
                    } else {
                        yizhifu.push(element)
                    }
                });
                console.log(yizhifu);
                console.log(daizhifu);

                if (res.data.body.length == 0) {
                    wx.showToast({
                        title: '暂无数据',
                        icon: 'none',
                        duration: 2000
                    })
                }
                that.setData({
                    // 'franchiseOrder': res.data.body,
                    yizhifu,
                    daizhifu
                })
            },
            fail: function(res) {
                wx.hideLoading()
                console.log('返回失败');
            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})